<?php
class Diff {
	public $same = false;
	
	public function __construct($f1, $f2) {
		$c1 = file($f1);
		$c2 = file($f2);
		
		// Trim the file
		foreach ($c1 as $i=>$l) {
			$l = trim($l);
			if (empty($l)) unset($c1[$i]);
		}
		
		foreach ($c2 as $i=>$l) {
			$l = trim($l);
			if (empty($l)) unset($c2[$i]);
		}
		
		// fit the array up
		$c1 = array_values($c1);
		$c2 = array_values($c2);
		
		if (count($c1) != count($c2)) {
			$this->same = false;
		}
		
		$this->same = true;
		foreach ($c1 as $i=>$l) {
			$l1  = trim($l);
			$l2  = trim($c2[$i]);
			$l1  = preg_replace('/[\s]+/',' ',$l1);
			$l2  = preg_replace('/[\s]+/',' ',$l2);
			if ($l1 != $l2)
				$this->same = false;
		}
	}
}

//$d = new Diff('C:\Users\Nat Pavasant\Desktop\a+b - Copy.c', 'C:\Users\Nat Pavasant\Desktop\a+b.c');
//var_dump($d);
